package com.github.binarywang.demo.wx.cp.controller;

import com.github.binarywang.demo.wx.cp.service.WeComSmartSheetService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/wx")
public class WeComSmartSheetController {

    @Autowired
    private WeComSmartSheetService weComSmartSheetService;

    /**
     * 获取智能表格记录
     *
     * @param docId   文档ID
     * @param sheetId 表格ID
     * @return 表格记录响应数据
     * @throws WxErrorException 微信API调用异常
     */
    @GetMapping("/getSheetRecords")
    public String getSheetRecords() throws WxErrorException {
        log.info("getSheetRecords...前端请求被触发");
        return weComSmartSheetService.getSheetRecords(1);
    }
    @GetMapping("/syncData")
    public String syncData() throws Exception {
        log.info("syncData...前端请求被触发");
        return weComSmartSheetService.syncData();
    }

    @GetMapping("/test")
    public String test() throws Exception {
        log.info("test...已运行");
        return "通路测试，成功！";
    }
}
